var _this;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    tall:'',
    weights:'',
    showFlag:false,
    sizeLists:[
      { iconUrl: '/images/shirt.png', title: '上衣尺码', content: '请选择胸围尺寸' },
      { iconUrl: '/images/pants.png', title: '裤子尺码', content: '请选择裤子尺寸' },
      { iconUrl: '/images/shoes.png', title: '鞋子尺码', content:'请选择鞋子尺寸'}
    ],
    checkboxItem:{
      left: [
        { name: '脸大', selected: true },
        { name: '肩宽', selected: false },
        { name: '平胸', selected: false },
        { name: '小肚腩', selected: false },
        { name: '胯偏宽', selected: false },
        { name: '腿短', selected: false },
        { name: '小腿粗', selected: false }
      ],
      right:[
        { name: '脖子短', selected: false },
        { name: '背厚', selected: false },
        { name: '大胸', selected: false },
        { name: '胳膊粗', selected: true },
        { name: '腰粗', selected: false },
        { name: '臀部大', selected: false },
        { name: '大腿粗', selected: false }
      ]
    },
    pages:1,
    uploadAvatar:'/images/uploadImg.png',
    one_photo: '/images/uploadImg.png',
    two_photo: '/images/uploadImg.png',
    three_photo: '/images/uploadImg.png'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    _this = this;
  },

  // 获取身高拼接cm
  getTall: ({ detail: { value } }) => _this.setData({ tall:value }),

  // 获取身高拼接cm
  getWeight: ({ detail: { value } }) => _this.setData({ weights: value }),
  
  
  // 上一步
  prev_address() {
    if (this.data.pages <= 1) {
      // 返回上一个页面
      wx.navigateBack({
        delta: 1
      })
      return false;
    }
    this.data.pages--;
    this.setData({
      pages: this.data.pages
    })
  },
  uploadAvatar() {
    wx.chooseImage({
      success: res =>{
        const tempFilePaths = res.tempFilePaths
        this.setData({
          uploadAvatar:res.tempFilePaths[0]
        })
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            user: 'test'
          },
          success(res) {
            const data = res.data
            // do something
          }
        })
      }
    })
  },
  uploadPhotoOne () {
    wx.chooseImage({
      success: res => {
        const tempFilePaths = res.tempFilePaths
        this.setData({
          one_photo: res.tempFilePaths[0]
        })
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            user: 'test'
          },
          success(res) {
            const data = res.data
            // do something
          }
        })
      }
    })
  },
  uploadPhotoTwo () {
    wx.chooseImage({
      success: res => {
        const tempFilePaths = res.tempFilePaths
        this.setData({
          two_photo: res.tempFilePaths[0]
        })
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            user: 'test'
          },
          success(res) {
            const data = res.data
            // do something
          }
        })
      }
    })
  },
  uploadPhotoThree () {
    wx.chooseImage({
      success: res => {
        const tempFilePaths = res.tempFilePaths
        this.setData({
          three_photo: res.tempFilePaths[0]
        })
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            user: 'test'
          },
          success(res) {
            const data = res.data
            // do something
          }
        })
      }
    })
  },
  // 下一步
  next_one(){
    
    if (isNaN(this.data.tall) && isNaN(this.data.weights)) {
      wx.showToast({
        icon:'none',
        duration:2000,
        title: '输入框必须是数字'
      })
      return false;
    }
    
    // 下一步
    
    this.data.pages >= 7 ? this.data.pages = 7 : this.data.pages++;

    this.setData({
      pages:this.data.pages
    })

    console.log('下一步');
  }
})